project (rotor-light-playground LANGUAGES CXX)

cmake_minimum_required(VERSION 3.8)
cmake_policy(SET CMP0069 NEW)

include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
if( supported )
    message(STATUS "IPO / LTO enabled")
    set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
    message(STATUS "IPO / LTO not supported: <${error}>")
endif()

add_subdirectory("lib/rotor-light")
target_include_directories(rotor_light PUBLIC "${LIBSTDCPP_HOME}/include")

add_executable(sample
    src/actor/dht.cpp
    src/actor/uart.cpp
    src/hw/board.cpp
    src/hw/exti.cpp
    src/hw/timer.cpp
    src/model/DHT11.cpp
    src/main.cpp
    src/supervisor.cpp
)
target_link_libraries(sample rotor_light)
target_include_directories(sample PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")

add_custom_command(TARGET sample
    POST_BUILD COMMAND ${CMAKE_SIZE_UTIL} sample)
